package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MCashier;
import com.ruoyi.system.service.IMCashierService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收据管理Controller
 * 
 * @author lzt
 * @date 2024-05-09
 */
@RestController
@RequestMapping("/system/cashier")
public class MCashierController extends BaseController
{
    @Autowired
    private IMCashierService mCashierService;

    /**
     * 查询收据管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:cashier:list')")
    @GetMapping("/list")
    public TableDataInfo list(MCashier mCashier)
    {
        startPage();
        List<MCashier> list = mCashierService.selectMCashierList(mCashier);
        return getDataTable(list);
    }

    /**
     * 导出收据管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:cashier:export')")
    @Log(title = "收据管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MCashier mCashier)
    {
        List<MCashier> list = mCashierService.selectMCashierList(mCashier);
        ExcelUtil<MCashier> util = new ExcelUtil<MCashier>(MCashier.class);
        util.exportExcel(response, list, "收据管理数据");
    }

    /**
     * 获取收据管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cashier:query')")
    @GetMapping(value = "/{receipt}")
    public AjaxResult getInfo(@PathVariable("receipt") Long receipt)
    {
        return success(mCashierService.selectMCashierByReceipt(receipt));
    }

    /**
     * 新增收据管理
     */
    @PreAuthorize("@ss.hasPermi('system:cashier:add')")
    @Log(title = "收据管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MCashier mCashier)
    {
        return toAjax(mCashierService.insertMCashier(mCashier));
    }

    /**
     * 修改收据管理
     */
    @PreAuthorize("@ss.hasPermi('system:cashier:edit')")
    @Log(title = "收据管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MCashier mCashier)
    {
        return toAjax(mCashierService.updateMCashier(mCashier));
    }

    /**
     * 删除收据管理
     */
    @PreAuthorize("@ss.hasPermi('system:cashier:remove')")
    @Log(title = "收据管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{receipts}")
    public AjaxResult remove(@PathVariable Long[] receipts)
    {
        return toAjax(mCashierService.deleteMCashierByReceipts(receipts));
    }
}
